/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MenuCadastrarPesqueiro.java
 *
 * Created on 17/11/2009, 13:26:48
 */

package JPaneis;

import Conector.Conector;
import siii.MenuPadrao;
import Data.Pesqueiro;
import java.sql.SQLException;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;


public class MenuDadosPesqueiro1 extends javax.swing.JPanel {

    private MenuPadrao menuPadrao;
    private Conector conector;
    private Pesqueiro pesqueiro = new Pesqueiro();
    private ImageIcon iconeOK;
    private ImageIcon iconeERRO;
    
    /** Creates new form MenuCadastrarPesqueiro */
    public MenuDadosPesqueiro1(MenuPadrao menu, Conector con) {
        initComponents();
        this.conector = con;
        this.menuPadrao = menu;
        this.pesqRP.setText("1");
        this.pesqRP.setEditable(false);
        iconeOK = new ImageIcon(getClass().getResource("/Images/fish-48x48ok.png"));
        iconeERRO = new ImageIcon(getClass().getResource("/Images/fish-48x48erro.png"));

        try {
            pesqueiro = conector.consultarDadosPequeiro();

            if (pesqueiro != null)
                this.setPesqueiroScreen(pesqueiro);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pesqEndereco = new javax.swing.JFormattedTextField();
        pesqNumero = new javax.swing.JTextField();
        jLabelNumero = new javax.swing.JLabel();
        jButtonCancelar = new javax.swing.JButton();
        jButtonSalvar = new javax.swing.JButton();
        pesqTel1 = new javax.swing.JFormattedTextField();
        jLabelTel1 = new javax.swing.JLabel();
        jLabelCidade = new javax.swing.JLabel();
        pesqCidade = new javax.swing.JFormattedTextField();
        jLabelBairro = new javax.swing.JLabel();
        jLabelCadastroPesqueiro = new javax.swing.JLabel();
        pesqBairro = new javax.swing.JFormattedTextField();
        jLabelNome = new javax.swing.JLabel();
        jLabelCEP = new javax.swing.JLabel();
        pesqNome = new javax.swing.JFormattedTextField();
        pesqCEP = new javax.swing.JFormattedTextField();
        jLabelRP = new javax.swing.JLabel();
        jLabelEmail = new javax.swing.JLabel();
        jLabelEstado = new javax.swing.JLabel();
        pesqRP = new javax.swing.JFormattedTextField();
        pesqEmail = new javax.swing.JFormattedTextField();
        pesqEstado = new javax.swing.JComboBox();
        jLabelEndereco = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabelCel = new javax.swing.JLabel();
        pesqCel = new javax.swing.JFormattedTextField();
        jLabelTel3 = new javax.swing.JLabel();
        pesqId = new javax.swing.JFormattedTextField();
        jLabelTel4 = new javax.swing.JLabel();
        pesqNextel = new javax.swing.JFormattedTextField();
        jLabelCel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        pesqObs = new javax.swing.JTextArea();
        pesqSite = new javax.swing.JFormattedTextField();
        jLabelSite = new javax.swing.JLabel();
        pesqCNPJ = new javax.swing.JFormattedTextField();
        jLabelCNPJ = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(1000, 500));

        pesqEndereco.setName("Logradouro"); // NOI18N

        pesqNumero.setName("Numero"); // NOI18N

        jLabelNumero.setText("Número");

        jButtonCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/peixe_cancelar.png"))); // NOI18N
        jButtonCancelar.setText("Cancelar");
        jButtonCancelar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonCancelarMouseClicked(evt);
            }
        });

        jButtonSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/peixe_add.png"))); // NOI18N
        jButtonSalvar.setText("Salvar");
        jButtonSalvar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonSalvarMouseClicked(evt);
            }
        });
        jButtonSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalvarActionPerformed(evt);
            }
        });

        try {
            pesqTel1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        pesqTel1.setName("Telefone"); // NOI18N

        jLabelTel1.setText("Telefone");

        jLabelCidade.setText("Cidade");

        pesqCidade.setName("Cidade"); // NOI18N

        jLabelBairro.setText("Bairro");

        jLabelCadastroPesqueiro.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabelCadastroPesqueiro.setText("Dados do Pesqueiro");

        pesqBairro.setName("Bairro"); // NOI18N

        jLabelNome.setText("Nome");

        jLabelCEP.setText("CEP");

        pesqNome.setName("Sobrenome"); // NOI18N

        try {
            pesqCEP.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#####-###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        pesqCEP.setName("CEP"); // NOI18N

        jLabelRP.setText("R.P");

        jLabelEmail.setText("E-mail");

        jLabelEstado.setText("Estado");

        pesqRP.setName("RG"); // NOI18N

        pesqEmail.setName("Email"); // NOI18N

        pesqEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SP", "AC", "AL", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MG", "MS", "PA", "PB", "PE", "PI", "PR", "RJ", "RR", "RO", "RS", "RN", "SC", "SE", "SP", "TO" }));
        pesqEstado.setName("Estado"); // NOI18N

        jLabelEndereco.setText("Endereço");

        jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/pesqueiro.png"))); // NOI18N

        jLabelCel.setText("Celular");

        try {
            pesqCel.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        pesqCel.setName("Telefone"); // NOI18N

        jLabelTel3.setText("ID");

        pesqId.setText(""); // NOI18N
        pesqId.setName("Telefone"); // NOI18N

        jLabelTel4.setText("Nextel");

        try {
            pesqNextel.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        pesqNextel.setName("Telefone"); // NOI18N

        jLabelCel1.setText("Demais Telefones");

        pesqObs.setColumns(20);
        pesqObs.setRows(5);
        pesqObs.setName("Observacao"); // NOI18N
        jScrollPane1.setViewportView(pesqObs);

        pesqSite.setName("Email"); // NOI18N

        jLabelSite.setText("Site");

        pesqCNPJ.setName("RG"); // NOI18N

        jLabelCNPJ.setText("CNPJ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabelCadastroPesqueiro, javax.swing.GroupLayout.DEFAULT_SIZE, 603, Short.MAX_VALUE)
                .addGap(273, 273, 273))
            .addGroup(layout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addComponent(jLabelCel1)
                .addGap(549, 549, 549)
                .addComponent(jButtonSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCancelar)
                .addGap(133, 133, 133))
            .addGroup(layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelTel1)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabelCel)
                                .addGap(98, 98, 98)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(pesqCel, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(481, 481, 481))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabelSite)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelBairro)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jLabelRP, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabelNome))
                                    .addComponent(jLabelEndereco))
                                .addGap(86, 86, 86)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(pesqNome, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
                                    .addComponent(pesqEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(pesqBairro, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jLabelEstado)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(pesqEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(pesqRP, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(41, 41, 41)
                                        .addComponent(jLabelCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(pesqCNPJ, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE)))
                                .addGap(29, 29, 29)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelNumero)
                                    .addComponent(jLabelCEP))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelCidade, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabelEmail))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
                                        .addComponent(pesqTel1, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(46, 46, 46)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jLabelTel3)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                                                .addComponent(pesqId, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jLabelTel4)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(pesqNextel, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(186, 186, 186))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(pesqSite, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(pesqEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                                    .addGap(88, 88, 88)
                                                    .addComponent(pesqCidade, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(pesqCEP)
                            .addComponent(pesqNumero, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE))
                        .addGap(326, 326, 326))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel13))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(jLabelCadastroPesqueiro, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pesqRP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelRP, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pesqCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelCNPJ))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pesqNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelNome))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pesqEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelEndereco)
                    .addComponent(jLabelNumero)
                    .addComponent(pesqNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelBairro, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pesqBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCidade)
                    .addComponent(pesqCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pesqEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelEstado)
                    .addComponent(jLabelCEP, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pesqCEP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pesqEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelSite, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pesqSite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelTel1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pesqTel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelTel4, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pesqNextel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pesqCel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelCel, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelTel3, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pesqId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButtonSalvar)
                        .addComponent(jButtonCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabelCel1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonCancelarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonCancelarMouseClicked
        // TODO add your handling code here:
        this.setPesqueiroScreen(pesqueiro);
        menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());
    }//GEN-LAST:event_jButtonCancelarMouseClicked

    private void jButtonSalvarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonSalvarMouseClicked
        // TODO add your handling code here:
        this.setPesqueiroScreen(pesqueiro);
        this.cleanScreen();
    }//GEN-LAST:event_jButtonSalvarMouseClicked

    private void jButtonSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalvarActionPerformed

        pesqueiro.setBairro(pesqBairro.getText());
        pesqueiro.setCep(pesqCEP.getText());
        pesqueiro.setCnpj(pesqCNPJ.getText());
        pesqueiro.setCidade(pesqCidade.getText());
        pesqueiro.setEmail(pesqEmail.getText());
        pesqueiro.setEstado(pesqEstado.getSelectedItem().toString());
        pesqueiro.setLogradouro(pesqEndereco.getText());
        pesqueiro.setNome(pesqNome.getText());
        pesqueiro.setNumero(pesqNumero.getText());
        pesqueiro.setTelefone(pesqTel1.getText());
        pesqueiro.setCelular(pesqCel.getText());
        pesqueiro.setNextel(pesqNextel.getText());
        pesqueiro.setId(pesqId.getText());
        pesqueiro.setDemais_tel(pesqObs.getText());
        pesqueiro.setSite(pesqSite.getText());
        try {
                    if (conector.atualizarDadosPesqueiro(pesqueiro)) {
                        JOptionPane.showMessageDialog(this, "Dados do pesqueiro: " + pesqueiro.getNome() + "\nForam atualizados", "Confirmação", JOptionPane.OK_OPTION, iconeOK);
                        menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());

                    } else {
                        JOptionPane.showMessageDialog(this, "Dados do Pesqueiro não atualizados", "Atenção", JOptionPane.WARNING_MESSAGE, iconeERRO);
                        //menuPadrao.trocaPanel2(menuPadrao.getMenuPrincipal());
                    }

                } catch (SQLException ex) {
                     ex.printStackTrace();
                     conector = new Conector();
                }
             // TODO add your handling code here:
    }//GEN-LAST:event_jButtonSalvarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCancelar;
    private javax.swing.JButton jButtonSalvar;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabelBairro;
    private javax.swing.JLabel jLabelCEP;
    private javax.swing.JLabel jLabelCNPJ;
    private javax.swing.JLabel jLabelCadastroPesqueiro;
    private javax.swing.JLabel jLabelCel;
    private javax.swing.JLabel jLabelCel1;
    private javax.swing.JLabel jLabelCidade;
    private javax.swing.JLabel jLabelEmail;
    private javax.swing.JLabel jLabelEndereco;
    private javax.swing.JLabel jLabelEstado;
    private javax.swing.JLabel jLabelNome;
    private javax.swing.JLabel jLabelNumero;
    private javax.swing.JLabel jLabelRP;
    private javax.swing.JLabel jLabelSite;
    private javax.swing.JLabel jLabelTel1;
    private javax.swing.JLabel jLabelTel3;
    private javax.swing.JLabel jLabelTel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JFormattedTextField pesqBairro;
    private javax.swing.JFormattedTextField pesqCEP;
    private javax.swing.JFormattedTextField pesqCNPJ;
    private javax.swing.JFormattedTextField pesqCel;
    private javax.swing.JFormattedTextField pesqCidade;
    private javax.swing.JFormattedTextField pesqEmail;
    private javax.swing.JFormattedTextField pesqEndereco;
    private javax.swing.JComboBox pesqEstado;
    private javax.swing.JFormattedTextField pesqId;
    private javax.swing.JFormattedTextField pesqNextel;
    private javax.swing.JFormattedTextField pesqNome;
    private javax.swing.JTextField pesqNumero;
    private javax.swing.JTextArea pesqObs;
    private javax.swing.JFormattedTextField pesqRP;
    private javax.swing.JFormattedTextField pesqSite;
    private javax.swing.JFormattedTextField pesqTel1;
    // End of variables declaration//GEN-END:variables

    //este método foi implementado para caso oi sistema cresca e exista mais de 1 pesqueiro
    private void cleanScreen() {
        pesqNome.setText("");
        pesqEndereco.setText("");
        pesqNumero.setText("");
        pesqBairro.setText("");
        pesqCidade.setText("");
        pesqCEP.setText("");
        pesqCNPJ.setText("");
        pesqEmail.setText("");
        pesqTel1.setText("");
        pesqCel.setText("");
        pesqNextel.setText("");
        pesqId.setText("");
        pesqObs.setText("");
        pesqSite.setText("");
        pesqEstado.setSelectedItem("SP");
    }

    public void setPesqueiroScreen(Pesqueiro setPesq) {
        pesqNome.setText(setPesq.getNome());
        pesqEndereco.setText(setPesq.getLogradouro());
        pesqNumero.setText(setPesq.getNumero());
        pesqBairro.setText(setPesq.getBairro());
        pesqCidade.setText(setPesq.getCidade());
        pesqCEP.setText(setPesq.getCep());
        pesqCNPJ.setText(setPesq.getCnpj());
        pesqEmail.setText(setPesq.getEmail());
        pesqTel1.setText(setPesq.getTelefone());
        pesqCel.setText(setPesq.getCelular());
        pesqNextel.setText(setPesq.getNextel());
        pesqId.setText(setPesq.getId());
        pesqSite.setText(setPesq.getSite());
        pesqEstado.setSelectedItem(setPesq.getEstado());
    }
}
